home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d20 / doorskl3.arc / SCREEN2.ASM < prev    next >
Assembly Source File  |  1992-01-15  |  9KB  |  540 lines

  1. ;
  2. ; PUBLIC DOMAIN
  3. ; (swiped from MSGED 2.00 archive and modified somewhat--MK)
  4. ;
  5.  
  6. .model large
  7.  
  8. extrn _vbase:word
  9. extrn _maxx:word
  10. extrn _maxy:word
  11. extrn _current_color:byte
  12. extrn _videomethod:word
  13. extrn _cls_clr:byte
  14.  
  15. public DCLS, DPUTC, DPUTCX, DPUTS, DPUTSX
  16. public DCLRWND, DSCROLLUP, DSCROLLDN
  17.  
  18. .CODE
  19.  
  20. DCLS    proc far        ;void pascal far dcls (void);
  21.  
  22.     push bp
  23.     mov bp,sp
  24.  
  25.     push di
  26.     mov es,_vbase        ; set the es segment to the bottom of video
  27.  
  28.     mov bx,_maxx
  29.     mov ax,_maxy
  30.     mul bl                ; determine size of screen in words
  31.  
  32.     mov cx,ax            ; set up the count for the screen size
  33.     xor di,di            ; point es:di to start of screen
  34.  
  35.     mov ah,_cls_clr     ; set the attribute
  36.     mov al,20h          ; write a space
  37.  
  38.     cld                 ; make sure we're going in the right direction...
  39.     repnz stosw            ; slam that sucker out to memory..
  40.  
  41.     mov ax,200h         ; move bios cursor to top of screen
  42.     mov bx,0h
  43.     mov dx,0h
  44.     int 10h
  45.  
  46.     pop di
  47.     pop bp
  48.  
  49.     ret
  50.  
  51. DCLS    endp
  52.  
  53. DPUTC   proc far        ;int pascal far dputc (int x,int y,char wr);
  54.  
  55.     push bp
  56.     mov bp,sp
  57.  
  58.     pushf
  59.     cld
  60.  
  61.     cmp _videomethod,1
  62.     je bsputc
  63.  
  64.     mov bx,[bp+6]        ; get the character to write
  65.     mov dx,[bp+8]        ; get the y location
  66.     mov es,_vbase        ; set up the video segment
  67.  
  68.     mov ax,_maxx
  69.     dec dl                ; off by one because of 1 base coords
  70.     mul dl
  71.     add ax,[bp+10]        ; get base video offset
  72.     dec ax                ; off by one because of 1 based coords
  73.     shl ax,1            ; double it (because of attribute)
  74.  
  75.     mov bh,_current_color
  76.  
  77.     xchg ax,bx
  78.     mov es:[bx],ax        ; put it on the screen
  79.  
  80.     popf
  81.     pop bp
  82.     ret 6
  83.  
  84. bsputc: mov ah,02h
  85.     mov cx,[bp+8]
  86.     mov dx,[bp+10]
  87.     mov dh,cl
  88.     dec dh
  89.     dec dl
  90.     mov bh,0
  91.     int 10h
  92.  
  93.     mov ax,[bp+6]
  94.     mov ah,09h
  95.     mov bh,0
  96.     mov cx,1
  97.     mov bl,_current_color
  98.     int 10h
  99.  
  100.     popf
  101.     pop bp
  102.     ret 6
  103.  
  104. DPUTC    endp
  105.  
  106. DPUTS   proc far        ;int pascal far dputs (int x,int y,char far *wr);
  107.  
  108.     push bp
  109.     mov bp,sp
  110.  
  111.     pushf
  112.     cld
  113.  
  114.     cmp _videomethod,1
  115.     je bsputs
  116.  
  117.     push di             ; save needed registers
  118.     push si
  119.     push ds
  120.  
  121.     mov ax,_maxx
  122.     mov es,_vbase        ; set up the video segment
  123.     mov dh,_current_color
  124.  
  125.     lds si,[bp+6]        ; get offset
  126.     mov bx,[bp+10]        ; get the y location
  127.     mov di,[bp+12]        ; get the x location
  128.  
  129.     dec bl                ; off by one because of 1 base coords
  130.     mul bl
  131.     add di,ax            ; get base video offset
  132.     dec di                ; off by one because of 1 based coords
  133.     shl di,1            ; double it (because of attribute)
  134.  
  135.     mov ah,dh            ; put the attribute in ah
  136.     mov dx,si
  137.  
  138.  
  139. l0:    lodsb                ; load character
  140.     cmp al,0            ; test for zero byte
  141.     jz l1                ; end of string
  142.     stosw                ; write character and attribute
  143.     jmp l0
  144.  
  145. l1:    sub si,dx            ; how many characters were written
  146.     mov ax,si
  147.     dec ax
  148.  
  149.     pop ds                ; restore registers
  150.     pop si
  151.     pop di
  152.  
  153.     popf
  154.  
  155.     pop bp
  156.     ret 8
  157.  
  158. bsputs: mov cx,[bp+10]
  159.     mov dx,[bp+12]
  160.     mov dh,cl
  161.     dec dh
  162.     dec dl
  163.     mov bh,0
  164.     
  165.     push ds
  166.     pop es
  167.     push si
  168.     push di
  169.     lds si,[bp+6]
  170.     mov di,si
  171.     mov bl,es:_current_color
  172.     mov cx,1
  173.  
  174. l5:    mov ah,2
  175.     int 10h
  176.     inc dl
  177.     mov ah,9
  178.     lodsb    
  179.     cmp al,0
  180.     jz l6
  181.     int 10h
  182.     jmp l5
  183.  
  184. l6:    mov ax,si
  185.     sub ax,di
  186.     dec ax
  187.     pop di
  188.     pop si
  189.     push es
  190.     pop ds
  191.  
  192.     popf
  193.  
  194.     pop bp
  195.     ret 8
  196.     
  197. DPUTS endp
  198.  
  199. DPUTCX proc far         ;int pascal far dputcx (int x,int y,char color,char wr);
  200.  
  201.     push bp
  202.     mov bp,sp
  203.  
  204.     pushf
  205.     cld
  206.  
  207.     cmp _videomethod,1
  208.     je bsputcx
  209.  
  210.     mov bx,[bp+6]       ; get the character to write
  211.     mov dx,[bp+10]      ; get the y location
  212.     mov es,_vbase       ; set up the video segment
  213.  
  214.     mov ax,_maxx
  215.     dec dl              ; off by one because of 1 base coords
  216.     mul dl
  217.     add ax,[bp+12]      ; get base video offset
  218.     dec ax              ; off by one because of 1 based coords
  219.     shl ax,1            ; double it (because of attribute)
  220.  
  221.     mov bh,[bp+8]       ; color to use
  222.  
  223.     xchg ax,bx
  224.     mov es:[bx],ax      ; put it on the screen
  225.  
  226.     popf
  227.     pop bp
  228.     ret 8
  229.  
  230. bsputcx: mov ah,02h
  231.     mov cx,[bp+10]
  232.     mov dx,[bp+12]
  233.     mov dh,cl
  234.     dec dh
  235.     dec dl
  236.     mov bh,0
  237.     int 10h
  238.  
  239.     mov ax,[bp+6]
  240.     mov ah,09h
  241.     mov bh,0
  242.     mov cx,1
  243.     mov bl,[bp+8]
  244.     int 10h
  245.  
  246.     popf
  247.     pop bp
  248.     ret 8
  249.  
  250. DPUTCX  endp
  251.  
  252. DPUTSX  proc far        ; int pascal far dputsx (int x,int y,char color,char far *wr);
  253.  
  254.     push bp
  255.     mov bp,sp
  256.  
  257.     pushf
  258.     cld
  259.  
  260.     cmp _videomethod,1
  261.     je bsputsx
  262.  
  263.     push di             ; save needed registers
  264.     push si
  265.     push ds
  266.  
  267.     mov ax,_maxx
  268.     mov es,_vbase       ; set up the video segment
  269.     mov dh,[bp+10]      ; color
  270.  
  271.     lds si,[bp+6]       ; get offset
  272.     mov bx,[bp+12]      ; get the y location
  273.     mov di,[bp+14]      ; get the x location
  274.  
  275.     dec bl              ; off by one because of 1 base coords
  276.     mul bl
  277.     add di,ax           ; get base video offset
  278.     dec di              ; off by one because of 1 based coords
  279.     shl di,1            ; double it (because of attribute)
  280.  
  281.     mov ah,dh           ; put the attribute in ah
  282.     mov dx,si
  283.  
  284.  
  285. l0x: lodsb              ; load character
  286.      cmp al,0           ; test for zero byte
  287.      jz l1x             ; end of string
  288.      stosw              ; write character and attribute
  289.      jmp l0x
  290.  
  291. l1x: sub si,dx          ; how many characters were written
  292.      mov ax,si
  293.      dec ax
  294.  
  295.     pop ds              ; restore registers
  296.     pop si
  297.     pop di
  298.  
  299.     popf
  300.  
  301.     pop bp
  302.     ret 10
  303.  
  304. bsputsx: mov cx,[bp+12]
  305.     mov dx,[bp+14]
  306.     mov dh,cl
  307.     dec dh
  308.     dec dl
  309.     mov bh,0
  310.  
  311.     push ds
  312.     pop es
  313.     push si
  314.     push di
  315.     lds si,[bp+6]
  316.     mov di,si
  317.     mov bl,[bp+10]
  318.     mov cx,1
  319.  
  320. l5x: mov ah,2
  321.      int 10h
  322.      inc dl
  323.      mov ah,9
  324.      lodsb
  325.      cmp al,0
  326.      jz l6x
  327.      int 10h
  328.      jmp l5x
  329.  
  330. l6x: mov ax,si
  331.      sub ax,di
  332.      dec ax
  333.      pop di
  334.      pop si
  335.      push es
  336.      pop ds
  337.  
  338.      popf
  339.  
  340.      pop bp
  341.      ret 10
  342.  
  343. DPUTSX endp
  344.  
  345. DCLRWND proc far
  346.     push bp
  347.     mov bp,sp
  348.  
  349.     push di
  350.     push si
  351.  
  352.     mov es,_vbase    ; video segment
  353.  
  354.     mov di,[bp+12]
  355.  
  356.     mov cx,[bp+6]
  357.     sub cx,[bp+10]    ; how many lines?
  358.     inc cx
  359.  
  360.     mov ax,_maxx
  361.     mov bx,[bp+10]
  362.     dec bl
  363.     mul bl
  364.     add di,ax
  365.     dec di
  366.     mov si,di
  367.  
  368.     mov ah,_current_color
  369.     mov al,20h
  370.  
  371.     mov bx,[bp+8]
  372.     sub bx,[bp+12]    ; how many columns
  373.     inc bx
  374.  
  375. l2: mov dx,bx
  376.     xchg cx,dx
  377.     shl di,1
  378.     rep stosw
  379.     add si,_maxx
  380.     mov di,si
  381.     xchg cx,dx
  382.     loop l2
  383.  
  384.     pop si
  385.     pop di
  386.  
  387.     pop bp
  388.     ret 8
  389.  
  390. DCLRWND endp
  391.  
  392. DSCROLLUP proc far
  393.  
  394.     push bp
  395.     mov bp,sp
  396.  
  397.     sub sp,2        ; allocate a local
  398.  
  399.     pushf
  400.  
  401.     push di         ; save registers
  402.     push si
  403.     push ds
  404.  
  405.     cld             ; set direction to forward
  406.  
  407.     mov al,_current_color
  408.     mov [bp-2],al
  409.  
  410.     mov es,_vbase    ; point to the video screen
  411.     mov ax,_maxx    ; how many columns on the screen
  412.     mov si,ax
  413.  
  414.     mov cx,[bp+6]
  415.     sub cx,[bp+10]    ; how many lines?
  416.  
  417.     mov di,[bp+12]    ; x offset of first line
  418.     mov bx,[bp+10]    ; y offset of first line
  419.     dec bl            ; adjust for 1 base
  420.     mul bl
  421.     add di,ax
  422.     dec di            ; first line offset in di
  423.  
  424.     shl si,1
  425.     shl di,1
  426.  
  427.     mov ax,si        ; save maxx * 2
  428.     add si,di        ; offset of second line in si
  429.  
  430.     push es
  431.     pop ds            ; point both at video
  432.  
  433.     mov bx,[bp+8]
  434.     sub bx,[bp+12]    ; how many columns
  435.     inc bx
  436.  
  437. l3: mov dx,bx
  438.     xchg cx,dx
  439.     push si         ; store this offset
  440.     rep movsw
  441.     pop di
  442.     mov si,ax
  443.     add si,di
  444.     xchg cx,dx
  445.     loop l3
  446.  
  447.     xchg cx,bx
  448.     mov ah,[bp-2]
  449.     mov al,20h
  450.     rep stosw
  451.  
  452.     pop ds            ; restore registers
  453.     pop si
  454.     pop di
  455.  
  456.     popf
  457.  
  458.     mov sp,bp        ; drop locals
  459.  
  460.     pop bp
  461.     ret 8
  462.  
  463. DSCROLLUP endp
  464.  
  465. DSCROLLDN proc far
  466.  
  467.     push bp
  468.     mov bp,sp
  469.  
  470.     sub sp,2        ; allocate a local
  471.  
  472.     pushf
  473.  
  474.     push di         ; save registers
  475.     push si
  476.     push ds
  477.  
  478.     cld             ; set direction to forward
  479.  
  480.     mov al,_current_color
  481.     mov [bp-2],al
  482.  
  483.     mov es,_vbase    ; point to the video screen
  484.     mov ax,_maxx    ; how many columns on the screen
  485.     mov si,ax
  486.  
  487.     mov cx,[bp+6]
  488.     sub cx,[bp+10]    ; how many lines?
  489.  
  490.     mov di,[bp+12]    ; x offset of first line
  491.     mov bx,[bp+6]    ; y offset of last line
  492.     dec bl            ; adjust for 1 base
  493.     mul bl
  494.     add di,ax
  495.     dec di            ; last line offset in si
  496.  
  497.     shl si,1
  498.     shl di,1
  499.  
  500.     mov ax,si        ; save maxx * 2
  501.     mov si,di
  502.     sub si,ax        ; offset of second to last line in di
  503.  
  504.     push es
  505.     pop ds            ; point both at video
  506.  
  507.     mov bx,[bp+8]
  508.     sub bx,[bp+12]    ; how many columns
  509.     inc bx
  510.  
  511. l4: mov dx,bx
  512.     xchg cx,dx
  513.     push si        ; store this offset
  514.     rep movsw
  515.     pop di
  516.     mov si,di
  517.     sub si,ax
  518.     xchg cx,dx
  519.     loop l4
  520.  
  521.     xchg cx,bx
  522.     mov ah,[bp-2]
  523.     mov al,20h
  524.     rep stosw
  525.  
  526.     pop ds            ; restore registers
  527.     pop si
  528.     pop di
  529.  
  530.     popf
  531.  
  532.     mov sp,bp        ; drop locals
  533.  
  534.     pop bp
  535.     ret 8
  536.  
  537. DSCROLLDN endp
  538.  
  539. end
  540.